#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
struct node
{
    string name, id;
    int grade;
};
int n, l, h;
bool cmp(node n1, node n2)
{
    return n1.grade > n2.grade;
}
int main()
{
    cin >> n;
    vector<node> stu(n);
    for (int i = 0; i < n; i++)
    {
        cin >> stu[i].name >> stu[i].id >> stu[i].grade;
    }
    cin >> l >> h;
    sort(stu.begin(), stu.end(), cmp);
    if (stu.begin()->grade < l)
    {
        cout << "NONE";
    }
    else
        for (auto it = stu.begin(); it != stu.end(); it++)
        {
            if(it->grade >= l && it->grade <= h)
                cout << it->name << " " << it->id << endl; 
        }
}